﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views {
    import flash.events.*;
    import reprise.events.*;
    import flash.display.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.vo.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.views.popups.*;
    import net.wooga.pets.views.components.*;
    import net.wooga.pets.constants.*;
    import net.wooga.pets.utils.*;
    import net.wooga.pets.models.world.*;

    public class LetterMediatorTypeB_W extends AbstractPopupMediator {

        public var languageModel:LanguageModel;
        public var letterModel:LetterModel;
        public var userModel:UserModel;
        public var environmentModel:EnvironmentModel;
        public var worldModel:WorldModel;
        private var _letterVO:LetterVO;

        override public function onRegister():void{
            super.onRegister();
            var _local1:String = String(this.view.data.id);
            this._letterVO = this.letterModel.getLetterById(_local1);
            var _local2:int = this._letterVO.number;
            var _local3 = "_queue_mode";
            this.addLabelButton(((("letter_" + this._letterVO.number) + "_button_label") + _local3));
            this.view.addCSSClass(this._letterVO.id);
            addLabel("title showcardGothicFontOutline", "letter_hints_header");
            var _local4:ClipComponent = RepriseUtils.addClipComponent(this.view, "signatureClip", AssetsLibrary.getMovieClip("signature"));
            this.view.addCSSClass(("letter" + _local2));
            MovieClip(_local4.clip).gotoAndStop(this.environmentModel.language);
            RepriseUtils.addComponent(this.view, ("images " + this._letterVO.id));
            RepriseUtils.addLabel(this.view, "myriadProFont copy copy1", this.languageModel.getTextByKey((("letter_" + _local2) + "_first_step")));
            RepriseUtils.addLabel(this.view, "myriadProFont copy copy2", this.languageModel.getTextByKey((("letter_" + _local2) + "_second_step")));
            ((!((this._letterVO.id == GameConstants.LETTER_FONTAIN))) && (RepriseUtils.addLabel(this.view, "myriadProFont copy copy3", this.languageModel.getTextByKey((("letter_" + _local2) + "_third_step")))));
            RepriseUtils.addLabel(this.view, "myriadProFont copy greetings", this.languageModel.getTextByKey("letter_hints_greetings"));
            dispatch(new InfoEvent(EventConstants.PLAY_EFFECT_SOUND, GameConstants.SOUND_OPEN_LETTER));
            dispatch(new TrackingEvent(TrackingConst.TRACK, TrackingConst.EVENT, {type:"letter", st1:this._letterVO.id, st2:"open"}));
        }
        private function addLabelButton(_arg1:String):void{
            RepriseUtils.addLabelButton(this.view, "letterButton", this.languageModel.getTextByKey(_arg1), this.letterButton_click, null, "myriadProFontOutline");
        }
        override protected function close():void{
            this.hide();
            dispatch(new InfoEvent(EventConstants.SEND_LETTER_STATE, this._letterVO.id));
            dispatch(new TrackingEvent(TrackingConst.TRACK, TrackingConst.EVENT, {type:"letter", st1:this._letterVO.id, st2:"close"}));
        }
        private function letterButton_click(_arg1:MouseEvent):void{
            this.hide();
            dispatch(new InfoEvent(EventConstants.LETTER_BUTTON_CLICKED, this._letterVO.id, {letterVO:this._letterVO}));
            dispatch(new TrackingEvent(TrackingConst.TRACK, TrackingConst.EVENT, {type:"letter", st1:this._letterVO.id, st2:"ok"}));
        }
        private function hide():void{
            this.view.mouseEnabled = false;
            this.view.addEventListener(TransitionEvent.ALL_TRANSITIONS_COMPLETE, this.letter_allTransitionsComplete);
            this.view.addCSSClass("fadeOut");
        }
        private function letter_allTransitionsComplete(_arg1:TransitionEvent):void{
            this.view.removeEventListener(TransitionEvent.ALL_TRANSITIONS_COMPLETE, this.letter_allTransitionsComplete);
            var _local2:InfoEvent = new InfoEvent(EventConstants.DESTROY_POPUP, null, this.view);
            dispatch(_local2);
        }
        private function get view():LetterPopupTypeB{
            return ((viewComponent as LetterPopupTypeB));
        }

    }
}//package net.wooga.pets.views 
